package prolog.terms
import scala.collection.mutable._

class Copier extends SystemObject {
  val dict = new LinkedHashMap[Var, Var]()

  override def action(place: Term): Term = {

    if (place.isInstanceOf[Var]) {
      val vplace = place.asInstanceOf[Var]
      val root = dict.get(vplace);
      root match {
        case None => {
          val res = new Var()
          dict.put(vplace, res)
          return res
        }
        case Some(v) => {
          return v
        }
      }
    } else return place
  }
}